package org.prem.collection;

import java.util.HashMap;
import java.util.HashSet;

public class HashCodeSample {
	
	public static void main(String args[]){
		DepartmentBO departmentBO = new DepartmentBO();
		departmentBO.setId(1);
		departmentBO.setDepartmentCode("JV");
		departmentBO.setDepartmentName("Java");
		System.out.println("departmentBO string---->"+departmentBO.toString());
		DepartmentBO departmentBO1 = new DepartmentBO();
		departmentBO1.setId(2);
		departmentBO1.setDepartmentCode("JV");
		departmentBO1.setDepartmentName("Java");
		DepartmentBO departmentBO2 = new DepartmentBO();
		departmentBO2.setId(3);
		departmentBO2.setDepartmentCode("O");
		departmentBO2.setDepartmentName("Oracle");
		System.out.println("departmentBO equals departmentBO1?--->"+departmentBO.equals(departmentBO1));
		System.out.println("departmentBO equals departmentBO2?--->"+departmentBO.equals(departmentBO2));
		
		//HashSet hashSet1 = new HashSet();
		HashMap<String, DepartmentBO> hashMap1 = new HashMap<String, DepartmentBO>(); 
		hashMap1.put("1", departmentBO);
		hashMap1.put("2", departmentBO);
		hashMap1.put("3", departmentBO2);
		System.out.println("departmentBO.hashCode----->"+departmentBO2.hashCode());
		
		DepartmentBO departmentBOTest = new DepartmentBO();
		departmentBOTest.setId(1);
		departmentBOTest.setDepartmentCode("O");
		departmentBOTest.setDepartmentName("Java");
		System.out.println("Contains 1----->"+hashMap1.containsValue(departmentBOTest));
		
		System.out.println("Contains 2----->"+hashMap1.containsValue(new DepartmentBO(1,"JV")));
		System.out.println("Contains 2----->"+hashMap1.containsValue(new DepartmentBO(100,"JV")));
		
		
		String name = "prem";
		System.out.println("name hashcode----->"+name.hashCode());
		
		Employee employee = new Employee(1,"Prem");
		System.out.println("employee.hashCode---------->"+employee.hashCode());
		System.out.println("employee---------->"+employee);
		Employee employee1 = new Employee(1,"Prem");
		System.out.println("employee1.hashCode---------->"+employee1.hashCode());
		System.out.println("employee1---------->"+employee1);
		//hashMap1.get(key);
		
		HashSet<DepartmentBO> hashSet = new HashSet<DepartmentBO>();
		hashSet.add(departmentBO);
		hashSet.add(departmentBO1);
		hashSet.add(departmentBO2);
		System.out.println("hashSet.contains(departmentBO)-------------->"+hashSet.contains(departmentBO));
		System.out.println("hashSet.contains(new DepartmentBO(1,JV)))-------------->"+hashSet.contains(new DepartmentBO(1,"JV")));
		System.out.println("hashSet.contains(new DepartmentBO(100,JV)))-------------->"+hashSet.contains(new DepartmentBO(100,"JV")));
	}

}
